const app = getApp()
Page({

  data: {
    form: {}
  },

  onLoad: function (options) {
    const form = JSON.parse(options.form)
    this.setData({ form })

  },
  copy() {
    const { form } = this.data;
    wx.setClipboardData({ data: form.order_id });
  },
  async onFinish() {
    const modal = await new Promise((resolve, reject) => {
      wx.showModal({
        title: '确认',
        content: '请确认确定已支付，并且备注姓名联系方式以便我们核对订单。',
        showCancel: true,
        cancelText: '未支付',
        cancelColor: '#000000',
        confirmText: '已支付',
        confirmColor: '#1B819E',
        success: (result) => {
          resolve(result)
        },
      });
    })
    if (modal.cancel) return 

    const { form } = this.data
    const res = await app.request({ url: `updateOrder`, data: { id: form.id, status: "已付款，待审核" }, method: "POST" })
    console.log(res);
    if(res.meta.status>=300) return app.showModal({content:"请求失败 "+res.meta.msg})
    await app.showModal({content:"订单已支付，待审核后发布"})
    wx.navigateBack({ delta: 1});
  },
})